<?php
  //Buffer larger content areas like the main page content
  ob_start();
  require_once("auth.php");

?>
<script type="text/javascript" src="js/validation.js"></script>
<script>
var count=0;

function load(thediv, thefile) /* 2 parameters passed into here: the id of the div container and the name of the page to go to */
{  
    if (window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest();
    }
    else
    {
        xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');  
    }
    xmlhttp.addEventListener("error", transferFailed, false);  
    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            document.getElementById( thediv ).innerHTML = xmlhttp.responseText;
        }
    }  
 
   xmlhttp.open('GET', thefile, true);
    xmlhttp.send();
	    
}

function transferFailed(evt) {  
  alert("An error occurred while transferring the file.");  
}

</script>
<?php 
include("config.php");
if(isset($_REQUEST['id']))
{
$id=$_REQUEST['id'];
$data=mysql_query("select * from shippers where ShipperID='$id'");
$no=mysql_num_rows($data);
if($no!=0)
{
	while($rec=mysql_fetch_assoc($data))
	{

?>

<form action="updateshippers.php" method="post"  enctype="multipart/form-data"  id="frmShippers">
<fieldset >
<legend style="color:#FD0002">Update  Shippers </legend>
			<div id="status"></div>

<table align="center" width="50%">
<tr> <td>Company Name</td><td><input type="hidden" name="id" value="<?php echo $id; ?>" />
<input type="text" name="txtCompanyName" id="txtCompanyName" value="<?php echo $rec['CompanyName']; ?>"></td></tr>

<tr> <td>Phone</td><td><input type="text" id="txtPhone" name="txtPhone" value="<?php echo $rec['Phone']; ?>"  onkeypress="return numbersonly(event);"></td></tr>

<tr><td><input type="button" value="Update Shipper" name="btnUpdateShipper" onclick="validateForm2('updateshippers.php','frmShippers','thediv','<img src=\'pleasewait.gif\'>');"  /></td></tr>
</table>
</fieldset>
  	</form>
<?php
}
}
}
else
{
?>
<form action="addshippers.php" method="post"  enctype="multipart/form-data" id="frmShippers">
<fieldset >
<legend style="color:#FD0002">Add Shippers </legend>
			<div id="status"></div>

<table align="center" width="50%">
<tr> <td>Company Name</td><td><input type="text" name="txtCompanyName" id="txtCompanyName">
</td></tr>
<tr> <td>Phone</td><td><input type="text" id="txtPhone" name="txtPhone" onkeypress="return numbersonly(event);"></td></tr>
<tr><td><input type="button" value="Add Shipper" name="btnAddShipper" onclick="validateForm2('addshipper.php','frmShippers','thediv','<img src=\'pleasewait.gif\'>');" />
</td></tr>
</table>
</fieldset>
  	</form>
	<?php
	}
	?>
	 <?php
  //Assign all Page Specific variables
  $pagemaincontent = ob_get_contents();
  ob_end_clean();
  $pagetitle = "Shippers";
  //Apply the template
  include("master.php");
?>    